<template>
	<view class="container">
		<block v-if="isload">
			<dd-search :isfixed="true"
				:placeholderText="'Please enter the booker is name or mobile phone number to search'"
				@getdata="getdata"></dd-search>
			<dd-tab style="top: 84rpx;" :itemdata="['all','Pending payment','pending review','completed','Refund']"
				:itemst="['all','0','1','3','10']" :st="st" :isfixed="true" @changetab="changetab"></dd-tab>
			<view class="order-content">
				<block v-for="(item, index) in datalist" :key="index">
					<view class="order-box" @tap="goto" :data-url="'bookingorderdetail?id=' + item.id">
						<view class="head">
							<view><text class="bold">{{item.linkman}}</text>{{item.tel}}</view>
							<view class="flex1"></view>
							<text v-if="item.status==0" class="st0">Pending payment</text>
							<text v-if="item.status==1 && item.check_status==0" class="st0">pending review</text>
							<text v-if="item.status==1 && item.check_status==-1" class="st4">turn down</text>
							<text v-if="item.status==2" class="st2">pending receipt</text>
							<text v-if="item.status==3" class="st3">completed</text>
							<text v-if="item.status==4" class="st4">closed</text>
						</view>
						<view class="h60">Predetermined time：{{item.booking_time}}</view>
						<block v-for="(item2, idx) in item.prolist" :key="idx">
							<view class="content" :style="idx+1==item.procount?'border-bottom:none':''">
								<view @tap.stop="goto" :data-url="'/restaurant/shop/product?id=' + item2.proid">
									<image :src="item2.pic"></image>
								</view>
								<view class="detail">
									<text class="t1">{{item2.name}}</text>
									<text class="t2">{{item2.ggname}}</text>
									<view class="t3"><text class="x1 flex1">₹{{item2.sell_price}}</text><text
											class="x2">×{{item2.num}}</text></view>
								</view>
							</view>
						</block>
						<view class="bottom">
							<text>
								<!-- total{{item.procount}}Pieces dishes --> Table number：{{item.tableName}} Actually
								paid:₹{{item.totalprice}}
							</text>
							<text v-if="item.refund_status==1" style="color:red"> Refunding₹{{item.refund_money}}</text>
							<text v-if="item.refund_status==2" style="color:red"> refunded₹{{item.refund_money}}</text>
							<text v-if="item.refund_status==3" style="color:red"> Refund request rejected</text>
						</view>
						<view class="bottom flex-y-center">
							<image :src="item.member.headimg"
								style="width:40rpx;height:40rpx;border-radius:50%;margin-right:10rpx" /><text
								style="font-weight:bold;color:#333;margin-right:8rpx">{{item.member.nickname}}</text>(ID:{{item.mid}})
						</view>
					</view>
				</block>
			</view>
			<nomore v-if="nomore"></nomore>
			<nodata v-if="nodata"></nodata>
		</block>
		<loading v-if="loading"></loading>
	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				opt: {},
				loading: false,
				isload: false,
				menuindex: -1,

				st: 'all',
				datalist: [],
				pagenum: 1,
				nomore: false,
				nodata: false,
				codtxt: "",
				keyword: ''
			};
		},

		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			if (this.opt && this.opt.st) {
				this.st = this.opt.st;
			}
			this.getdata();
		},
		onPullDownRefresh: function() {
			this.getdata();
		},
		onReachBottom: function() {
			if (!this.nodata && !this.nomore) {
				this.pagenum = this.pagenum + 1;
				this.getdata(true);
			}
		},
		methods: {
			getdata: function(loadmore, keyword) {
				if (!loadmore) {
					this.pagenum = 1;
					this.datalist = [];
				}
				var that = this;
				var pagenum = that.pagenum;
				var st = that.st;
				if (typeof keyword == 'undefined') {
					keyword = that.keyword;
				} else {
					that.keyword = keyword;
				}
				that.nodata = false;
				that.nomore = false;
				that.loading = true;
				app.post('ApiAdminRestaurantBookingOrder/index', {
					keyword: keyword,
					st: st,
					pagenum: pagenum
				}, function(res) {
					that.loading = false;
					var data = res.datalist;
					if (pagenum == 1) {
						that.datalist = data;
						if (data.length == 0) {
							that.nodata = true;
						}
						that.loaded();
					} else {
						if (data.length == 0) {
							that.nomore = true;
						} else {
							var datalist = that.datalist;
							var newdata = datalist.concat(data);
							that.datalist = newdata;
						}
					}
				});
			},
			changetab: function(st) {
				this.st = st;
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				this.getdata();
			},
		}
	};
</script>
<style>
	.h60 {
		line-height: 60rpx;
	}

	.container {
		width: 100%;
		margin-top: 174rpx
	}

	.order-content {
		display: flex;
		flex-direction: column
	}

	.order-box {
		width: 94%;
		margin: 10rpx 3%;
		padding: 16rpx 3%;
		background: #fff;
		border-radius: 8px
	}

	.order-box .head {
		display: flex;
		width: 100%;
		border-bottom: 1px #f4f4f4 solid;
		height: 70rpx;
		line-height: 70rpx;
		overflow: hidden;
	}

	.order-box .head .bold {
		font-size: 34rpx;
		color: #333;
		margin-right: 20rpx;
		font-weight: bold;
	}

	.order-box .head .f1 {
		display: flex;
		align-items: center;
		color: #333
	}

	.order-box .head .f1 image {
		width: 34rpx;
		height: 34rpx;
		margin-right: 4px
	}

	.order-box .head .st0 {
		width: 140rpx;
		color: #ff8758;
		text-align: right;
	}

	.order-box .head .st1 {
		width: 140rpx;
		color: #ffc702;
		text-align: right;
	}

	.order-box .head .st2 {
		width: 140rpx;
		color: #ff4246;
		text-align: right;
	}

	.order-box .head .st3 {
		width: 140rpx;
		color: #999;
		text-align: right;
	}

	.order-box .head .st4 {
		width: 140rpx;
		color: #bbb;
		text-align: right;
	}

	.order-box .content {
		display: flex;
		width: 100%;
		padding: 16rpx 0px;
		border-bottom: 1px #f4f4f4 dashed;
		position: relative
	}

	.order-box .content:last-child {
		border-bottom: 0;
	}

	.order-box .content image {
		width: 140rpx;
		height: 140rpx;
	}

	.order-box .content .detail {
		display: flex;
		flex-direction: column;
		margin-left: 14rpx;
		flex: 1
	}

	.order-box .content .detail .t1 {
		font-size: 26rpx;
		line-height: 36rpx;
		margin-bottom: 10rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.order-box .content .detail .t2 {
		height: 46rpx;
		line-height: 46rpx;
		color: #999;
		overflow: hidden;
		font-size: 26rpx;
	}

	.order-box .content .detail .t3 {
		display: flex;
		height: 40rpx;
		line-height: 40rpx;
		color: #ff4246;
	}

	.order-box .content .detail .x1 {
		flex: 1
	}

	.order-box .content .detail .x2 {
		width: 100rpx;
		font-size: 32rpx;
		text-align: right;
		margin-right: 8rpx
	}

	.order-box .bottom {
		width: 100%;
		padding: 10rpx 0px;
		border-top: 1px #f4f4f4 solid;
		color: #555;
	}

	.order-box .op {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		width: 100%;
		padding: 10rpx 0px;
		border-top: 1px #f4f4f4 solid;
		color: #555;
	}

	.btn1 {
		margin-left: 20rpx;
		width: 160rpx;
		height: 60rpx;
		line-height: 60rpx;
		color: #fff;
		border-radius: 3px;
		text-align: center
	}

	.btn2 {
		margin-left: 20rpx;
		width: 160rpx;
		height: 60rpx;
		line-height: 60rpx;
		color: #333;
		background: #fff;
		border: 1px solid #cdcdcd;
		border-radius: 3px;
		text-align: center
	}
</style>
